package com.surfilter.risk.enums;

/**
 * CodeStateEnum
 * Dis:返回状态的枚举类
 * Created by grom on 2017/5/2.
 */
public enum CodeStateEnum {
    SUCCESS(0,0),
    FAIL(-1,-1);

    private int state;
    private int stateInfo;

    //枚举类型的构造器应该是私有的
    private CodeStateEnum(int state, int stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    public int getState() {
        return state;
    }

    public int getStateInfo() {
        return stateInfo;
    }

    public static CodeStateEnum stateOf(int index){
        for(CodeStateEnum codeStateEnum : values()){
            if(codeStateEnum.getState() == index){
                return codeStateEnum;
            }
        }
        return null;
    }
}
